import { ApiProperty } from '@nestjs/swagger';
import { Length, IsNotEmpty } from 'class-validator';

import { IsSameValue } from '../../utils/schema.validate';

export class LoginUserDto {
  @ApiProperty({
    description: '用户名',
    default: 'string',
  })
  @IsNotEmpty({ message: '用户名不能为空' })
  @Length(6, 20, { message: '用户名长度6-20' })
  username: string;

  @ApiProperty({
    description: '密码',
    default: 'string',
  })
  @IsNotEmpty({ message: '密码不能为空' })
  @Length(6, 100, { message: '密码长度6-100' })
  password: string;
}

export class CreateUserDto extends LoginUserDto {
  @ApiProperty({
    description: '确认密码',
    default: 'string',
  })
  @IsSameValue('password', { message: '重复密码不一致' })
  confirmPassword: string;
}
